package org.example.springbook.enums;

import java.util.Arrays;

public enum BookStatusEnum {
    DELETED(0,"删除"),
    NORMAL(1,"可借阅"),
    FORBIDDEN(2,"不可借阅");
    private Integer code;
    private String desc;
    BookStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    public Integer getCode() {
        return code;
    }
    public String getDesc() {
        return desc;
    }
    public static BookStatusEnum getStatusByCode(Integer code) {
        return Arrays.stream(BookStatusEnum.values()).filter(x->x.getCode()==code).findFirst().get();
    }
}
